package org.yuchen.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * 
 * 实现Servlet的三种方式：
 * 1. 实现Servlet接口
 * 
 * @author Temp
 *
 */
public class LoginServlet implements Servlet{

	public void destroy() {
		
	}

	public ServletConfig getServletConfig() {
		return null;
	}

	public String getServletInfo() {
		return null;
	}

	public void init(ServletConfig arg0) throws ServletException {
		
	}

	public void service(ServletRequest request, ServletResponse response)
			throws ServletException, IOException {
		String username = request.getParameter("username");
		System.out.println("username is " + username);
		
		// render response
		PrintWriter writer = response.getWriter();
		writer.write("hello " + username);
		
		writer.flush();
	}

}
